/*
Copyright (c) [2019年5月1日] [吴超]
[MBT_studio] is licensed under Mulan PSL v2.
You can use this software according to the terms and conditions of the Mulan PSL v2.
You may obtain a copy of Mulan PSL v2 at:
		 http://license.coscl.org.cn/MulanPSL2
THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
See the Mulan PSL v2 for more details.
*/
#pragma once

#include "向量.h"

#include "../../S_Physics.h"



S_Physics*	f_PhysPBF_创建物理引擎();
void		f_PhysPBF_销毁物理引擎(S_Physics* phy);




S_物理体*	f_PhysPBF_创建物理流体(S_Physics* phy, S_物理材质& 材质, const S_Tranform& t, uint32 数量);
S_物理体*	f_PhysPBF_创建物理边界(S_Physics* phy, vec3 size, const S_Tranform& t);
S_物理体*	f_PhysPBF_创建刚体(S_物理材质* 材质);
S_物理体*	f_PhysPBF_创建粒子发射(uint32 数量, S_物理材质* 材质);




void		f_PBF_set粒子半径(S_Physics* phy, float32 r);
void		f_PBF_set域(S_Physics* phy, const vec3& size, const vec3& offset, float32 r);

bool		f_PhysPBF_切换物理体类型(S_物理体* body, E_物理体类型 类型);
bool		f_PBF_添加物体(S_Physics* phy, S_物理体* body);
bool		f_PBF_物体是否存在(S_Physics* phy, S_物理体* body);
void		f_PhysPBF_add静态碰撞网格(S_Physics* phy, std::vector<vec3>& vert, std::vector<uvec3>& index);



void		f_PhysPBF_设置流体粒子数量(S_Physics* phy, S_物理体* body, uint32 num);
void		f_PhysPBF_set粒子发射数量(S_物理体* body, uint32 数量);
void		f_PhysPBF_set飞溅粒子数量(S_Physics* phy, uint32 数量);
void		f_PBF_set流体粒子区间(S_物理体* body, const uvec2& 区间);

void		f_PBF_重置发射体(S_物理体* body);
void		f_PhysPBF_取粒子坐标(S_Physics* phy, S_物理体* body, vec3* c);
void		f_PhysPBF_取粒子速度(S_Physics* phy, S_物理体* body, vec3* c);

S_体素*		f_PhysPBF_get物体体素(S_物理体* body);
uint64		f_PBF_get粒子总数(S_Physics* phy);
S_域区*		f_PBF_get域属性(S_Physics* phy);
float32		f_PBF_get粒子大小(S_Physics* phy);
void		f_PBF_get域中粒子(S_Physics* phy, vec3 coord, std::vector<vec3>& particle);
uvec2		f_PBF_get物理体粒子区间(S_物理体* body);
uvec4		f_PBF_get粒子发射区间(S_物理体* body, float32 速率);
uint64		f_PBF_get发射总数(S_物理体* body);


vec3*		f_PhysPBF_映射流体粒子坐标(S_Physics* phy, S_物理体* body);
vec3*		f_PhysPBF_映射流体粒子速度(S_Physics* phy, S_物理体* body);
vec3*		f_PhysPBF_映射流体粒子外力(S_Physics* phy, S_物理体* body);



void		f_PhysPBF_施加单方向外力(S_Physics* phy, S_物理体* body, const vec3& f);




void		f_PBF_构建域流体(S_Physics* phy, S_物理体* body);
void		f_PhysPBF_构建静态碰撞空间划分(S_Physics* phy, float32 最小单元大小);



void	f_PBF_流体数据写入到顶点缓存(S_Physics* 解算器, vec4* data);
void	f_PBF_体素数据写入到顶点缓存(S_Physics* 解算器, std::vector<vec4>& data);
void	f_PBF_静态碰撞空间树写入缓存(const S_Physics* 解算器, std::vector<vec4>& data);
void	f_PBF_静态碰撞单元树写入缓存(const S_Physics* 解算器, std::vector<vec4>& data);



